﻿////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright file="AbstractGameListBackup.cs" company="SingularityShift.com">
// Copyright (c) 2010 SingularityShift.com. All rights reserved.
// </copyright>
// <author>Ben McClure</author>
// <email>ben@singularityshift.com</email>
// <date>11/19/2010</date>
// <summary>Implements the abstract game list backup class</summary>
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace GameLib.Backups
{
    using GameLib.Games;

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    /// <summary>   Abstract game list backup. </summary>
    ///
    /// <remarks>   Ben McClure, 11/19/2010. </remarks>
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    public abstract class AbstractGameListBackup : AbstractBackup, IGameListBackup
    {
        #region Fields

        /// <summary> The games </summary>
        private IGameCollection<IGame> _games;

        #endregion Fields

        #region Properties

        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Gets or sets the mods. </summary>
        ///
        /// <value> The mods. </value>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public IGameCollection<IGame> Games
        {
            get
            {
                return _games;
            }
            protected set
            {
                _games = value;
            }
        }

        #endregion Properties

        #region AbtractBackup Member Overrides

        public override int Backup(IBackupWriter writer)
        {
            writer.Write(this);
            if (writer.Count >= 1)
            {
                return Games.Count;
            }
            else
            {
                return writer.Count;
            }
        }

        public override int Restore(IBackupReader reader)
        {
            IGameListBackup restored = (IGameListBackup)reader.Read(this);
            OutputPath = restored.OutputPath;
            Created = restored.Created;
            Games = restored.Games;

            return Games.Count;
        }

        #endregion AbtractBackup Member Overrides
    }
}